package main

import (
	"encoding/json"
	"fmt"
	"reflect"
)

type Person struct {
	Name string `json:"name"`
	Age  uint8  `json:"age"`
}

func (p Person) GetName() string {
	return p.Name
}

func (p *Person) SetName(newName string) {
	p.Name = newName
}

var print = fmt.Println

func numT(nums ...int) {
	fmt.Println(reflect.TypeOf(nums))
	for _, v := range nums {
		print(v)
	}
}

func main() {
	p := Person{"xiaobai", 6}
	print(p.GetName())
	getName1 := p.GetName
	print(getName1())
	getName2 := (Person).GetName
	print("outer:", getName2(p))
	setName := (*Person).SetName
	setName(&p, "xiaohei")
	json, err := json.Marshal(p)
	if err != nil {
		print("json convert failure")
	} else {
		print(string(json))
	}
	print(reflect.TypeOf(p).Field(0).Tag.Get("json"))
	s := []int{1, 2, 3}
	numT(s...)

}
